package com.dhj.yygh.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/*
InitializingBean接口为bean提供了初始化方法的方式，
它只包括 afterPropertiesSet() 方法，凡是继承该接口的类，在初始化 bean 的时候会执行该方法。
 */
@Component
public class ConstantOssPropertiesUtiils implements InitializingBean {

    @Value("${aliyun.oss.endpoint}")
    private String ossEndpoint;

    @Value("${aliyun.oss.accessKeyId}")
    private String aliyunAccessKeyId;

    @Value("${aliyun.oss.secret}")
    private String aliyunSecret;

    @Value("${aliyun.oss.bucket}")
    private String aliyunBucket;


    public static String OSS_ENDPOINT;
    public static String ALIYUN_ACCESS_KEY_ID;
    public static String ALIYUN_SECRET;
    public static String ALIYUN_BUCKET;

    @Override
    public void afterPropertiesSet() {
        OSS_ENDPOINT = ossEndpoint;
        ALIYUN_ACCESS_KEY_ID = aliyunAccessKeyId;
        ALIYUN_SECRET = aliyunSecret;
        ALIYUN_BUCKET = aliyunBucket;
    }
}
